package com.JobWebGem.system.service.impl;

import com.JobWebGem.system.common.ErrorCode;
import com.JobWebGem.system.exception.BusinessException;
import com.JobWebGem.system.mapper.HrMapper;
import com.JobWebGem.system.model.dto.hr.HrQueryRequest;
import com.JobWebGem.system.model.entity.Hr;
import com.JobWebGem.system.model.vo.HrVO;
import com.JobWebGem.system.model.vo.UserVO;
import com.JobWebGem.system.service.HrService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author renli
* @description 针对表【hr(存储HR信息)】的数据库操作Service实现
* @createDate 2024-12-02 21:18:40
*/
@Service
public class HrServiceImpl extends ServiceImpl<HrMapper, Hr>
    implements HrService {

    @Resource
    private HrMapper hrMapper;

    @Override
    public Page<HrVO> getHrQuery(Page<HrVO> paramPage, HrQueryRequest hrQueryRequest) {
        // 自定义分页查询
        List<HrVO> hrList = hrMapper.getQuery(paramPage, hrQueryRequest);
        if (hrList == null) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询失败");
        }
        for (HrVO hrVO : hrList) {
            if (hrVO.getSex() == "0") {
                hrVO.setSex("男");
            } else {
                hrVO.setSex("女");
            }
        }
        // 设置分页结果
        paramPage.setRecords(hrList);
        return paramPage;
    }
}




